<?php

/**
 * Trade form base class.
 *
 * @method Trade getObject() Returns the current form's model object
 *
 * @package    truetrader
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseTradeForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'trader_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Trader'), 'add_empty' => false)),
      'stock_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('StockExchange'), 'add_empty' => false)),
      'horizon_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TradeHorizon'), 'add_empty' => false)),
      'trade'           => new sfWidgetFormInputText(),
      'entry'           => new sfWidgetFormInputText(),
      'contract_number' => new sfWidgetFormInputText(),
      'support'         => new sfWidgetFormInputText(),
      'resistance'      => new sfWidgetFormInputText(),
      'objective'       => new sfWidgetFormInputText(),
      'drop_out'        => new sfWidgetFormInputText(),
      'description'     => new sfWidgetFormTextarea(),
      'published_at'    => new sfWidgetFormDateTime(),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'trader_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Trader'))),
      'stock_id'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('StockExchange'))),
      'horizon_id'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('TradeHorizon'))),
      'trade'           => new sfValidatorString(array('max_length' => 100)),
      'entry'           => new sfValidatorInteger(),
      'contract_number' => new sfValidatorInteger(),
      'support'         => new sfValidatorInteger(),
      'resistance'      => new sfValidatorInteger(),
      'objective'       => new sfValidatorInteger(),
      'drop_out'        => new sfValidatorInteger(),
      'description'     => new sfValidatorString(array('max_length' => 500, 'required' => false)),
      'published_at'    => new sfValidatorDateTime(array('required' => false)),
      'created_at'      => new sfValidatorDateTime(),
      'updated_at'      => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('trade[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Trade';
  }

}
